package code.main.modle.command
{
	import code.app.AppDmList;
	import code.debug.DebugCtrl;
	import code.main.modle.table.Player;
	import code.phpnet.GlobalConfig;
	import code.phpnet.Remoting;
	
	/**
	 *登陆命令 
	 * @author YY
	 * 
	 */
	public class LoginCmd
	{
		private var _loginCb:Function;//登陆成功回调
		public function LoginCmd(cb:Function)
		{
			_loginCb = cb;
			loginSucCb();
		}
		
		private function loginSucCb():void {
			//测试数据
//			DebugCtrl.getInstance().initPlayerData();
			var player:Player = AppDmList.getInstance().player;
			player.gameId = String(GlobalConfig.instance.mid);
			player.userKey =  GlobalConfig.instance.mtkey;
			Remoting.getInstance().userRo.getUserInfo(xxFunc , player.gameId);
			function xxFunc(arr:Array):void {
				if(arr) {
					if(arr[0]) {
//						player.gameMoney = 100000;
//						player.giftId = 1;
//						player.seatId = 1;
//						player.platformMoney = 20000;
//						player.titleId = 2;
						player.userName = arr[0][3];
						player.pic = arr[0][4];			
						player.gender = arr[0][5];
					}
					if(arr[1]){
						player.gameMoney = arr[1][0];   //用户游戏币数
						player.level = arr[1][1];  //用户等级
						player.exp = arr[1][2];  //经验值
						player.vipLevel = arr[1][3]; //VIP等级
						player.giftId = arr[1][4]; //用户礼物
						player.loginCountContinue = arr[1][5]; //用户连续登陆天数
//						$aG['uscore'],  //用户比赛积分
//						$aG['ustatus'], //用户状态,0正常,1已封号
					}
				}
				if(Boolean(_loginCb)) {
					_loginCb();
				}
			}
		}
	}
}